/*******************************************************************************
 * Copyright (C), 2014, BeeIoT Tech. Co., Ltd. 
 * FileName:      SIM900A.h
 * Author:        lvxin 
 * Version :      1.0
 * Date:          2014-07-29 10:39:34
 * Description:
 * Function List: // 主要函数及其功能
 * 1. ------- 
 * History:
 * <author>   <time>                <version >  <desc> 
 * lvxin      2014-07-29 10:39:34   1.0         build this moudle 
 ******************************************************************************/
#ifndef  SIM900A_H
#define  SIM900A_H


/*******************************************************************************
 *  *INCLUDES
 *  */
#include <stdio.h>
#include <string.h>
#include "dev_platform.h"
#include "sim900a_api.h"
#include "gprs.h"
#include "option.h"
#include "dpalarm.h"
#include "conv.h"
#include "smset.h"

/*******************************************************************************
 *  *TYPEDEFS
 *  */
  //短信发送状态
  typedef struct msg_stat
  {
    char flag;
    char *num;
  }msg_stat_t;


typedef unsigned char  romchar;
//收到SIM900A回复的数据
typedef struct SIM900A_recmsg
{
  char *msg_head;                //消息头
  char *msg_tail;           //消息尾
  void (*func)(char *msg);  //消息处理
}SIM900A_recmsg_t;

/*******************************************************************************
 *  *PUBLIC FUNCTIONS
 *  */
void SIM900A_refresh(void);//更新系统状态并执行相应操作
int      SIM900A_init(option_t *option); //初始化SIM900A
int      SIM900A_open(void); //SIM900A开机
void     SIM900A_reboot(void); //SIM900A硬件重启
void     SIM900A_main_loop(void); //主循环

int      SIM900A_query_balance(void); //发送查询余额短信

int      SIM900A_set_time(uint16_t time);  //设置时间

uint8_t  SIM900A_get_year(void); //获得年
uint16_t SIM900A_get_timestamp(void);//获取系统当前时间
uint32_t SIM900A_get_device_id(void); //获取设备ID
option_t*SIM900A_get_options(void); //获取全局设置
uint8_t  SIM900A_get_monthday(void); //获得当月的日
#define SIM900A_read    SIM900A_core_getch    

int   SIM900A_sync_time(void);  //同步时间
//获取系统保存的手机号码
char *SIM900A_get_telnum(void); //获取系统保存的手机号
void SIM900A_check_regs(void); //检查并处理sim卡注册状态
#if (PLATFORM == LPC1114)
void TIMER32_0_IRQHandler (void);
void timer0Init (void);
#endif
#if (PLATFORM == LINUX)
void *SIM900A_thread_cycle_check_regs(void *arg); //定时检测网络注册状态线程
 
#endif

#endif  /*SIM900A_H*/

